package com.yalemang.universalindicator;

import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.yalemang.uindicator.Adapter;

public class TestAdapter extends Adapter<TestAdapter.TestViewHolder> {

    @NonNull
    @Override
    public TestViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_view, parent, false);
        return new TestViewHolder(view);
    }

    @Override
    protected int locationDeviation(boolean isPositiveScroll) {
        if (isPositiveScroll) {
            return 2;
        } else {
            return -2;
        }
    }

    @Override
    protected void selectStatus(TestViewHolder holder, int position) {
        holder.view.setBackgroundColor(Color.BLUE);
    }

    @Override
    protected void unSelectStatus(TestViewHolder holder, int position) {
        Log.d("Ellen2020", "未选：" + position);
        holder.view.setBackgroundColor(Color.GRAY);
    }

    @Override
    public int getItemCount() {
        return 100;
    }

    public static class TestViewHolder extends BaseViewHolder {
        public View view = findViewById(R.id.view);

        public TestViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
